<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
    <script src="./lib/axios.js"></script>
</head>
<body>
    <button>发送请求</button>
    <button>取消请求</button>
</body>
<script type="module">
const btns = document.querySelectorAll("button");
let xhr;
btns[0].onclick = function(){
	// if(xhr) xhr.abort();
    btns[1].click();
	// XML:数据结构
    // http:请求协议
    // Request:请求
    xhr = new XMLHttpRequest();
	xhr.responseType="json";
	// 准备
	xhr.open("get","http://zhangpeiyue.com/scoreList");
	// 发送
    xhr.send();
	xhr.onload = function(){
		console.log(xhr.response)
    }
	xhr.onabort = function(){
		console.log("取消请求")
    }


}
btns[1].onclick = function(){
    if(xhr) xhr.abort();
}
</script>
</html>